<div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
    <p class="pull-left" style="font-size:16px; line-height:30px;"><strong><?php echo $this->translate('广告设置'); ?></strong></p>
    <p class="pull-right">
        <a href="<?php echo $this->url('admintheme/default'); ?>" class="btn btn-small"><i class="icon-arrow-left"></i> <?php echo $this->translate('返回专题列表'); ?></a>&nbsp;
        <a href="<?php echo $this->myviewalias()->dbshopHelpUrl('theme_set'); ?>" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看帮助说明'); ?></a>
    </p>
</div>
<table class="table table-hover">
    <thead style="background:#CCC;">
    <tr>
        <th width="4%">ID</th>
        <th width="20%"><?php echo $this->translate('广告名称'); ?></th>
        <th width="20%"><?php echo $this->translate('广告类型'); ?></th>
        <th width="20%"><?php echo $this->translate('广告标记'); ?></th>
        <th width="10%"><?php echo $this->translate('设置状态'); ?></th>
        <th width="11%"><?php echo $this->translate('操作'); ?></th>
    </tr>
    </thead>
    <?php
    $adTypeNameArray = array('image'=>$this->translate('图片'), 'slide'=>$this->translate('幻灯片'), 'text'=>$this->translate('文字'), 'code'=>$this->translate('代码'));
    if($this->ad_set_list) { foreach ($this->ad_set_list as $item_value) { ?>
        <tr>
            <td><?php echo $item_value['item_id']; ?></td>
            <td><?php echo $this->escapeHtml($item_value['item_title']); ?></td>
            <td><?php echo $adTypeNameArray[$this->ad_ini[$item_value['item_code']]['type']]; ?></td>
            <td><?php echo $this->escapeHtml($item_value['item_code']); ?></td>
            <td>
                <?php
                $setState = (isset($item_value['theme_ad_id']) and $item_value['theme_ad_id'] > 0) ? true : false;
                echo $setState ? $this->translate('已设置') : $this->translate('未设置');
                ?>
            </td>
            <td>
                <a href="<?php echo $this->url('admintheme/default',array('action'=>'adSet'), array('query'=>array('theme_id'=>$item_value['theme_id'], 'item_id'=>$item_value['item_id']))); ?>"><?php echo $this->translate('编辑'); ?></a>
                <?php if($setState) { ?>
                    <span>|</span>
                    <a href="javascript:;" onclick="return ad_clear_js(<?php echo $item_value['theme_ad_id']; ?>, <?php echo $item_value['item_id']; ?>);"><?php echo $this->translate('清除'); ?></a>
                <?php } ?>
            </td>
        </tr>
    <?php } } ?>
</table>

<script>
    function ad_clear_js(theme_ad_id, item_id) {
        if(window.confirm('<?php echo $this->translate('您确实要清除该广告吗？'); ?>')) {
            $.post("<?php echo $this->url('admintheme/default',array('action'=>'adClear')); ?>",{theme_ad_id:theme_ad_id, item_id:item_id},
                function(data){
                    if(data == 'true') {
                        window.location.href='<?php echo $this->url('admintheme/default', array('action'=>'adList'), array('query'=>array('theme_id'=>$this->theme_info->theme_id))); ?>';
                        return true;
                    } else {
                        alert(data);
                    }
                });
        }
        return false;
    }
</script>